﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryMangementSystem.BookQuery
{
    public partial class BookQueryById : Form
    {
        public BookQueryById()
        {
            InitializeComponent();
        }
        LibraryEntities1 dbContext = new LibraryEntities1();
        private void button1_Click(object sender, EventArgs e)
        {
            var BookId = textBoxQueryById.Text;
            List<BookInfo> list = dbContext.BookInfo.Where(B => B.BookID == BookId).ToList();
            dataGridView1.Rows.Clear();
            foreach (BookInfo book in list)
            {
                dataGridView1.Rows.Add(book.BookID.Trim(),book.ISBN.Trim(),book.Title.Trim(),book.Publish.Trim(),
                    book.Author.Trim(),book.Words,book.Publisherlnfo !=null ? book.Publisherlnfo.Publisher.Trim():null,book.Number,book.Price,
                    book.Keyword.Trim(),book.Abstract.Trim());
            }
        }
    }
}
